package com.bilibili.juc;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
 * @author 小泽
 * @create 2022-09-19  9:17
 * 记得每天敲代码哦
 */
public class CompletableFutureNoVoid {
    public static void main(String[] args) {
        /**
         * 方法描述:
         * @Author 胡昊泽
         * @Date 2022/9/16 14:54
         * @param :
         * @return void 无返回值的
         */

        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        try {
            System.out.println(completableFuture.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }


}
